home *** CD-ROM | disk | FTP | other *** search
- Path: comsearch.com!tnasca
- From: Thuan Nguyen <thnguyen@comsearch.com>
- Newsgroups: comp.lang.c++
- Subject: Re: A question about declaring/passing arrays of structures
- Date: 17 Jan 1996 22:48:47 GMT
- Organization: ComSearch, Inc
- Message-ID: <4djucf$ehi@gateway.comsearch.com>
- References: <4djhdc$kp3@kira.cc.uakron.edu>
- NNTP-Posting-Host: arcturus.comsearch.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.1N (X11; I; SunOS 4.1.4 sun4c)
- X-URL: news:4djhdc$kp3@kira.cc.uakron.edu
-
- tberg@dax.cc.uakron.edu (timothy a berg) wrote:
- > I have recently been having trouble getting a program to work. It
- >consists of 6 variables, which are all arrays of structures. It seems
- >that when I pass them to a function, (located in another file), the
- >compiler will flag a fatal error on some of them. They are all defined
- >properly in a '.h' file, and linked to from the main program file,
- >(containing the 'main' function). There is nothing really unique about
- >the functions that work. Most of them consist of a few character
- >variables, a few integers, and 5 of the 6 contain a character array, set
- >to a certain length by a constant.
- > The error that I get is a 'General Protection Error' at 0001:3???,
- >which seems low in memory. But, when I comment out a for-next loop
- >that is immediately after the function call, I get a 'Stack Fault' error
- >at ALMOST the same location. I'm baffled. I've had assembler, and
- >several programming courses, but this one puzzles me.
- > Does anybody have a possible solution? If so, e-mail PERSONALLY,
- >as I don't get to read the news often. Your help is VERY MUCH
- >appreciated, as I have been trying to remedy this problem for almost 4
- >months now, with no success!!
- >
- >Tim Berg
- >
-
- how about including this in the .h file
-
- ..
- define your structure here
- ...
- #ifndef MAIN_BODY
- yours_tructure a;
- #else
- extern your_structure a;
- #endif
-
- and in the main program
-
- #define MAIN_BODY
- #include <yours.h>
- #undef MAIN_BODY
-
- main()
- {
- }
-
-